﻿
namespace Aeon.Emulator.Instructions.FPU
{
    internal static class Fist
    {
        [Opcode("DF/2 m16", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void StoreInt16(VirtualMachine vm, out short dest)
        {
            dest = (short)vm.Processor.FPU.ST0;
        }

        [Opcode("DB/2 m32", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void StoreInt32(VirtualMachine vm, out int dest)
        {
            dest = (int)vm.Processor.FPU.ST0;
        }
    }

    internal static class Fistp
    {
        [Opcode("DF/3 m16", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void StoreInt16(VirtualMachine vm, out short dest)
        {
            dest = (short)vm.Processor.FPU.ST0;
            vm.Processor.FPU.Pop();
        }

        [Opcode("DB/3 m32", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void StoreInt32(VirtualMachine vm, out int dest)
        {
            dest = (int)vm.Processor.FPU.ST0;
            vm.Processor.FPU.Pop();
        }

        [Opcode("DF/7 m64", OperandSize = 16 | 32, AddressSize = 16 | 32)]
        public static void StoreInt64(VirtualMachine vm, out long dest)
        {
            dest = (long)vm.Processor.FPU.ST0;
            vm.Processor.FPU.Pop();
        }
    }
}
